package com.cr.front.vehicle.controller;

import com.cr.common.response.JsonResult;
import com.cr.front.base.response.PageData;
import com.cr.front.vehicle.pojo.query.DayRentVehicleInfoQuery;
import com.cr.front.vehicle.pojo.query.MonthRentVehicleInfoQuery;
import com.cr.front.vehicle.pojo.vo.VehicleIndexVO;
import com.cr.front.vehicle.pojo.vo.VehicleVO;
import com.cr.front.vehicle.pojo.vo.monthVehicleInfoVO;
import com.cr.front.vehicle.service.VehicleService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(tags = "车辆模块")
@RestController
@RequestMapping("/vehicle")
public class VehicleController {
    @Autowired
    private VehicleService vehicleService;

    @GetMapping("/selectIndexVehicles/{rentType}")
    public JsonResult selectIndexVehicles(@PathVariable Character rentType){
        List<VehicleIndexVO> vehicleIndexVO = vehicleService.selectIndexVehicles(rentType);
        return JsonResult.success(vehicleIndexVO);
    }

    @GetMapping("/dayRentVehicleInfo/dayRentVehicleInfoQuery")
    public JsonResult dayRentVehicleInfo(DayRentVehicleInfoQuery dayRentVehicleInfoQuery  ){
        //List<dayRentVehicleInfoVO> dayRentVehicleInfoVO = vehicleService.dayRentVehicleInfo(dayRentVehicleInfoQuery);
        PageData data = vehicleService.dayRentVehicleInfo(dayRentVehicleInfoQuery);
        return JsonResult.success(data);
    }

    @GetMapping("/monthVehicleInfo")
    public JsonResult monthVehicleInfo(MonthRentVehicleInfoQuery monthRentVehicleInfoQuery){
        monthVehicleInfoVO monthVehicleInfoVO = vehicleService.monthVehicleInfoVO(monthRentVehicleInfoQuery);
        return JsonResult.success(monthVehicleInfoVO);
    }

    @GetMapping("/titleVehicleInfo")
    public JsonResult titleVehicleInfo(MonthRentVehicleInfoQuery monthRentVehicleInfoQuery){
        monthVehicleInfoVO monthVehicleInfoVO = vehicleService.monthVehicleInfoVO(monthRentVehicleInfoQuery);
        return JsonResult.success(monthVehicleInfoVO);
    }

    @GetMapping("{id}")
    public JsonResult getDetail(@PathVariable("id") Long id){
        VehicleVO vehicleVO = vehicleService.getDetail(id);
        return JsonResult.success(vehicleVO);
    }

    @GetMapping("recommend/{id}")
    public JsonResult getRecommend(@PathVariable("id") Long id){
        List<VehicleVO> list = vehicleService.getRecommend(id);
        return JsonResult.success(list);
    }


}
